#pragma once


#include "GameLogic.h"
#include "atlimage.h"

class GameUi
{
public:
	GameUi(void);
	~GameUi(void);
public:
	void Paint(CDC *dc);
	void PaintDebug(CDC *dc);
	void RePaint(CDC*);
	void PaintGameOver(CDC*dc);
	void PaintGameOverText(CDC*dc);
	void PaintIntegral(CDC*);
	void PaintClear(CDC *dc,int m_depth=0);
	void PaintNextSequare(CDC *dc);
	void DrawSequare(CDC *dc);
	void DrawOldSequare(CDC*);
	void SetGameSize(CDialog*);
	int GetGameSize();
	GAME_CODE Timer(/*CDialog*,UINT_PTR*/);
	void ChangeDown();
	void ChageUp();
	void Up();
	void Left();
	void Right();
	void AddSpeed(){m_game_logic->AddSpeed();}
	void SubSpeed(){m_game_logic->SubSpeed();}
	void DrawImage(int,CDC*,const CRect&);
	//void Clear();
	//int GetPictureWidth(){return m_game_sequare;}
private:
	void Init();
	void GetSequareRect(int i,int j,CRect *rect)
	{
		rect->top = m_game_rect.top + i*m_game_sequare;
		rect->bottom = rect->top + m_game_sequare;
		rect->left = m_game_rect.left + j*m_game_sequare;
		rect->right = rect->left + m_game_sequare;
	}
	void GetIntegralRect(CRect *rect)
	{
		rect->top = 10;
		rect->left = 10;
		rect->right = 100;
		rect->bottom = 40;
	}
	void GetGameOverRect(CRect *grect)
	{
		CRect rect;
		GetSequareRect(0,0,&rect);
		grect->top = rect.top;
		grect->left = rect.left;
		GetSequareRect(GameLogic::num_x - 1,GameLogic::num_y - 1,&rect);
		grect->right = rect.right;
		grect->bottom = rect.bottom;
		grect->top = grect->Height()/3;
	}
	
private:
	CRect m_game_rect;
	CFont *m_font_max;
	int m_game_sequare;
	GameLogic *m_game_logic;
	CImage m_image[IMAGE_NUM];
	//
	CBrush m_game_background;
	CBrush m_game_sequare_color[SEQUARE_NUM];
	//
	CRITICAL_SECTION m_section; 
};
